package com.example.crawler;

import com.example.crawler.youtube.YoutubeExtractorManager;
import com.example.crawler.youtube.model.ConvertResult;
import com.example.crawler.youtube.model.YoutubeExtractorResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/")
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class YoutubeVideoExtractorApplication {

    @Autowired
    private YoutubeExtractorManager youtubeExtractorManager;

    public static void main(String[] args) {
        SpringApplication.run(YoutubeVideoExtractorApplication.class, args);
    }

    @GetMapping
    public ConvertResult<YoutubeExtractorResult> testConvertYoutuVideo() {
        String url = "https://www.youtube.com/watch?v=avcq7hWFSbU2";
        ConvertResult<YoutubeExtractorResult> result = youtubeExtractorManager.convertYoutubeVideo(url);

        return result;
    }
}
